import React, { Component,useState} from 'react'

import {flushSync} from 'react-dom'

export default class App extends Component {
  state={
    count:0
  }
  btn=()=>{

      this.setState({count:this.state.count+1})

    console.log(this.state.count);
  }
  render() {
    return (
      <div>
        {console.log("render",this.state.count)}
        <button onClick={this.btn}>dianji{this.state.count} +1</button>
        <Child/>
        <Child/>
      </div>
    )
  }
}

function Child(){
  const [count, setCount] = useState(0);
  const handleClick=()=>{
    setCount(count+1)
  }
  return <>
    <button onClick={handleClick}>点击了{count}次</button>
  </>
}
